/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "members")
public class Members extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Members";
	public static final String ALIAS_MEMBER_ID = "memberId";
	public static final String ALIAS_CITY_ID = "cityId";
	public static final String ALIAS_LOGIN_NAME = "loginName";
	public static final String ALIAS_PASSWORD = "password";
	public static final String ALIAS_EMAIL = "email";
	public static final String ALIAS_TYPE = "type";
	public static final String ALIAS_LEVEL = "level";
	public static final String ALIAS_STATUS = "status";
	public static final String ALIAS_MSG_COUNT = "msgCount";
	public static final String ALIAS_POINTS = "points";
	public static final String ALIAS_MONEY = "money";
	public static final String ALIAS_CREATE_DATE = "createDate";
	public static final String ALIAS_LAST_LOGIN = "lastLogin";
	public static final String ALIAS_LAST_LOGIN_IP = "lastLoginIp";
	
	//date formats
	public static final String FORMAT_CREATE_DATE = DATE_FORMAT;
	public static final String FORMAT_LAST_LOGIN = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * memberId       db_column: memberId 
     */ 	
	
	private java.lang.Long memberId;
    /**
     * cityId       db_column: cityId 
     */ 	
	
	private java.lang.Long cityId;
    /**
     * loginName       db_column: loginName 
     */ 	
	@NotBlank @Length(max=50)
	private java.lang.String loginName;
    /**
     * password       db_column: password 
     */ 	
	@NotBlank @Length(max=500)
	private java.lang.String password;
    /**
     * email       db_column: email 
     */ 	
	@Email @Length(max=255)
	private java.lang.String email;
    /**
     * type       db_column: type 
     */ 	
	
	private java.lang.Integer type;
    /**
     * level       db_column: level 
     */ 	
	
	private java.lang.Integer level;
    /**
     * status       db_column: status 
     */ 	
	
	private java.lang.Integer status;
    /**
     * msgCount       db_column: msgCount 
     */ 	
	
	private java.lang.Integer msgCount;
    /**
     * points       db_column: points 
     */ 	
	
	private java.lang.Integer points;
    /**
     * money       db_column: money 
     */ 	
	
	private java.lang.Float money ;
    /**
     * createDate       db_column: createDate 
     */ 	
	@NotNull 
	private java.util.Date createDate;
    /**
     * lastLogin       db_column: lastLogin 
     */ 	
	@NotNull 
	private java.util.Date lastLogin;
    /**
     * lastLoginIp       db_column: lastLoginIP 
     */ 	
	@Length(max=50)
	private java.lang.String lastLoginIp;
	//columns END


	public Members(){
	}

	public Members(
		java.lang.Long memberId
	){
		this.memberId = memberId;
	}

	

	public void setMemberId(java.lang.Long value) {
		this.memberId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "memberId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberId() {
		return this.memberId;
	}
	
	@Column(name = "cityId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getCityId() {
		return this.cityId;
	}
	
	public void setCityId(java.lang.Long value) {
		this.cityId = value;
	}
	
	@Column(name = "loginName", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public java.lang.String getLoginName() {
		return this.loginName;
	}
	
	public void setLoginName(java.lang.String value) {
		this.loginName = value;
	}
	
	@Column(name = "password", unique = false, nullable = false, insertable = true, updatable = true, length = 500)
	public java.lang.String getPassword() {
		return this.password;
	}
	
	public void setPassword(java.lang.String value) {
		this.password = value;
	}
	
	@Column(name = "email", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getEmail() {
		return this.email;
	}
	
	public void setEmail(java.lang.String value) {
		this.email = value;
	}
	
	@Column(name = "type", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getType() {
		return this.type;
	}
	
	public void setType(java.lang.Integer value) {
		this.type = value;
	}
	
	@Column(name = "level", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getLevel() {
		return this.level;
	}
	
	public void setLevel(java.lang.Integer value) {
		this.level = value;
	}
	
	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(java.lang.Integer value) {
		this.status = value;
	}
	
	@Column(name = "msgCount", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getMsgCount() {
		return this.msgCount;
	}
	
	public void setMsgCount(java.lang.Integer value) {
		this.msgCount = value;
	}
	
	@Column(name = "points", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getPoints() {
		return this.points;
	}
	
	public void setPoints(java.lang.Integer value) {
		this.points = value;
	}
	
	@Column(name = "money", unique = false, nullable = true, insertable = true, updatable = true, length = 12)
	public java.lang.Float getMoney() {
		return this.money;
	}
	
	public void setMoney(java.lang.Float value) {
		this.money = value;
	}
	
	@Transient
	public String getCreateDateString() {
		return DateConvertUtils.format(getCreateDate(), FORMAT_CREATE_DATE);
	}
	public void setCreateDateString(String value) {
		setCreateDate(DateConvertUtils.parse(value, FORMAT_CREATE_DATE,java.util.Date.class));
	}
	
	@Column(name = "createDate", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getCreateDate() {
		return this.createDate;
	}
	
	public void setCreateDate(java.util.Date value) {
		this.createDate = value;
	}
	
	@Transient
	public String getLastLoginString() {
		return DateConvertUtils.format(getLastLogin(), FORMAT_LAST_LOGIN);
	}
	public void setLastLoginString(String value) {
		setLastLogin(DateConvertUtils.parse(value, FORMAT_LAST_LOGIN,java.util.Date.class));
	}
	
	@Column(name = "lastLogin", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getLastLogin() {
		return this.lastLogin;
	}
	
	public void setLastLogin(java.util.Date value) {
		this.lastLogin = value;
	}
	
	@Column(name = "lastLoginIP", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getLastLoginIp() {
		return this.lastLoginIp;
	}
	
	public void setLastLoginIp(java.lang.String value) {
		this.lastLoginIp = value;
	}
	
	
	private Set publishInfos = new HashSet(0);
	public void setPublishInfos(Set<PublishInfo> publishInfo){
		this.publishInfos = publishInfo;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "members")
	public Set<PublishInfo> getPublishInfos() {
		return publishInfos;
	}
	
	private Set myCommends = new HashSet(0);
	public void setMyCommends(Set<MyCommend> myCommend){
		this.myCommends = myCommend;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "members")
	public Set<MyCommend> getMyCommends() {
		return myCommends;
	}
	
	private Set myContacts = new HashSet(0);
	public void setMyContacts(Set<MyContact> myContact){
		this.myContacts = myContact;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "members")
	public Set<MyContact> getMyContacts() {
		return myContacts;
	}
	
	private Set myFavorites = new HashSet(0);
	public void setMyFavorites(Set<MyFavorite> myFavorite){
		this.myFavorites = myFavorite;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "members")
	public Set<MyFavorite> getMyFavorites() {
		return myFavorites;
	}
	
	private Set commentss = new HashSet(0);
	public void setCommentss(Set<Comments> comments){
		this.commentss = comments;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "members")
	public Set<Comments> getCommentss() {
		return commentss;
	}
	
	private City city;
	public void setCity(City city){
		this.city = city;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "cityId",nullable = false, insertable = false, updatable = false) 
	})
	public City getCity() {
		return city;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("MemberId",getMemberId())
			.append("CityId",getCityId())
			.append("LoginName",getLoginName())
			.append("Password",getPassword())
			.append("Email",getEmail())
			.append("Type",getType())
			.append("Level",getLevel())
			.append("Status",getStatus())
			.append("MsgCount",getMsgCount())
			.append("Points",getPoints())
			.append("Money",getMoney())
			.append("CreateDate",getCreateDate())
			.append("LastLogin",getLastLogin())
			.append("LastLoginIp",getLastLoginIp())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getMemberId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Members == false) return false;
		if(this == obj) return true;
		Members other = (Members)obj;
		return new EqualsBuilder()
			.append(getMemberId(),other.getMemberId())
			.isEquals();
	}
}

